home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJINC106.ARJ / GRAPHICS.H < prev    next >
C/C++ Source or Header  |  1992-03-09  |  3KB  |  126 lines

  1. /* This is file graphics.h */
  2. /*
  3. ** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954
  4. **
  5. ** This file is distributed under the terms listed in the document
  6. ** "copying.dj", available from DJ Delorie at the address above.
  7. ** A copy of "copying.dj" should accompany this file; if not, a copy
  8. ** should be available from where this file was obtained.  This file
  9. ** may not be distributed without a verbatim copy of "copying.dj".
  10. **
  11. ** This file is distributed WITHOUT ANY WARRANTY; without even the implied
  12. ** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. */
  14.  
  15. /* History:15,50 */
  16. #ifndef _GRAPHICS_H_
  17. #define _GRAPHICS_H_
  18.  
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22.  
  23. typedef enum {
  24.   GR_80_25_text,
  25.   GR_default_text,
  26.   GR_width_height_text,
  27.   GR_biggest_text,
  28.   GR_320_200_graphics,
  29.   GR_default_graphics,
  30.   GR_width_height_graphics,
  31.   GR_biggest_noninterlaced_graphics,
  32.   GR_biggest_graphics
  33. } GR_graphics_modes;
  34.  
  35. #ifdef __cplusplus
  36. void GrSetMode(int which, int width=0, int height=0);
  37. #else
  38. void GrSetMode();
  39. #endif
  40.  
  41. void GrSetColor(int c, int r, int g, int b);
  42. int GrAllocColor(int r, int g, int b); /* shared, read-only */
  43. int GrAllocCell(void); /* unshared, read-write */
  44. void GrQueryColor(int n, int *r, int *g, int *b);
  45. void GrFreeColor(int c);
  46. int GrWhite(void);
  47. int GrBlack(void);
  48.  
  49. /* or a color with GrXOR to "xor" the color onto the screen */
  50. #define GrXOR           0x100
  51. /* GrNOCOLOR is used for "no" color */
  52. #define GrNOCOLOR       0x100
  53.  
  54. void GrPlot(int x, int y, int c);
  55. int GrPixel(int x, int y);
  56.  
  57. int GrMaxX(void);
  58. int GrMaxY(void);
  59. int GrSizeX(void);
  60. int GrSizeY(void);
  61.  
  62. void GrLine(int x, int y, int x2, int y2, int c);
  63.  
  64. void GrTextXY(int x, int y, char *text, int fg, int bg);
  65.  
  66. #ifdef __cplusplus
  67. }
  68.  
  69. typedef enum {
  70.   BlitSrc,
  71.   BlitDest,
  72.   BlitXor,
  73. } GrBlitFunc;
  74.  
  75. class GrRegion;
  76.  
  77. GrRegion *GrScreenRegion();
  78.  
  79. void Blit(GrRegion *src,
  80.           GrRegion *dest, int dx, int dy,
  81.           GrBlitFunc function);
  82. void Blit(GrRegion *src, int sx, int sy, int sw, int sh,
  83.           GrRegion *dest, int dx, int dy,
  84.           GrBlitFunc function);
  85.  
  86. class GrRegion {
  87. public:
  88.   int flags;
  89.   int color;
  90.  
  91.   GrRegion *parent;
  92.   int rel_x, rel_y, abs_x, abs_y;
  93.  
  94.   int width;
  95.   int height;
  96.   int row_scale;
  97.   unsigned char *data;  /* for read/write operations *EXCEPT* bcopy/memcpy */
  98.   unsigned char *rdata; /* for read via bcopy/memcpy */
  99.   unsigned char *wdata; /* for write via bcopy/memcpy */
  100.  
  101.   GrRegion();
  102.   GrRegion(int width, int height); /* memory buffer */
  103.  ~GrRegion();
  104.   GrRegion *SubRegion(int x, int y, int w, int h);
  105.  
  106.   int  MaxX();
  107.   int  MaxY();
  108.   int  SizeX();
  109.   int  SizeY();
  110.  
  111.   void Plot(int x, int y, int c=-1);
  112.   void Line(int x1, int y1, int x2, int y2, int c=-1);
  113.   void HLine(int x1, int x2, int y, int c=-1);
  114.   void VLine(int x, int y1, int y2, int c=-1);
  115.   void Rectangle(int x1, int y1, int x2, int y2, int c=-1); /* outline */
  116.   void Box(int x, int y, int w, int h, int c=-1); /* filled */
  117.  
  118.   void Text(int x, int y, char *text, int fg=-1, int bg=-1);
  119.  
  120.   int  Point(int x, int y);
  121. };
  122.  
  123. #endif
  124.  
  125. #endif
  126.